#include "Stdafx.h"
#include "Core.h"

#include <intrin.h>
#pragma intrinsic(__rdtsc)

using namespace Vortex::Wrapper;
using namespace System::Threading;

#pragma unmanaged

unsigned __int64 ReadCPUTicks() {
	return __rdtsc();
}

#pragma managed

unsigned __int64 Core::GetCPUTicks() {
	return ReadCPUTicks();
}

unsigned __int64 Core::CalcCPUFrequency() {
	unsigned __int64 start = ReadCPUTicks();
	Thread::Sleep(MEASURE_TIME_MS);
	return (ReadCPUTicks() - start) * (1000 / MEASURE_TIME_MS);
}